<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BSPairEntity
 *
 * @author jianfeng
 */
class BSPairEntity extends BPairEntity{
    //put your code here
    public function getModelClass($data = NULL) {
        //parent::getModelClass($data);
        $mainObjClass = get_class($this->mainObj);
        $mClass = preg_replace("/^BS/", "BSM", $mainObjClass);
        //support group, for example, BSpaceGroup model class look like BMSpaceApp
        if ($this->mainObj instanceof BGroup)
            $mClass = preg_replace('/Group/', '', $mClass);
        if ($this->mainObj instanceof BApp || $this->mainObj instanceof BAppGroup) {
            $mClass = 'BMApp';
        }
        $pairObjClass = get_class($this->pairObj);
        if ($this->pairObj instanceof BApp || $this->pairObj instanceof BAppGroup)
            $mClass = $mClass . 'App';
        else {
            $mClass = $mClass . preg_replace("/^BS/", '', $pairObjClass);
            //support group, for example, BSpaceGroup model class look like BMSpaceApp
            if ($this->pairObj instanceof BGroup)
                $mClass = preg_replace('/Group/', '', $mClass);
        }

        if ($this->pairObj2 != NULL) {
            $pairObj2Class = get_class($this->pairObj2);
            if ($this->pairObj2 instanceof BApp || $this->pairObj2 instanceof BAppGroup)
                $mClass = $mClass . 'App';
            else {
                $mClass = $mClass . preg_replace("/^BS/", '', $pairObj2Class);
                //support group, for example, BSpaceGroup model class look like BMSpaceApp
                if ($this->pairObj2 instanceof BGroup)
                    $mClass = preg_replace('/Group/', '', $mClass);
            }

        }

        return $mClass;
    }
}
